package com.yinhaochuan.prase;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper;

public class PDFBoxA {
	
	public String  getText(String file) throws Exception {
		String pdfFile = file;
		PDDocument document = null;
		String string = "";
		
		document = PDDocument.load(pdfFile);
		
		PDFTextStripper stripper = new PDFTextStripper();
		
		string = stripper.getText(document);
		if (document!=null) {
			document.close();
		}
		
		return string;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PDFBoxA a = new PDFBoxA();
		
		String string = null;
		try {
			string = a.getText("./data/pdf/To someone I like.pdf");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(string);
	}

}
